package com.dcivision.framework.taglib.channel;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.dcivision.framework.ApplicationException;
import com.dcivision.workflow.taglib.RelatedObjectInfoTag;

public class AjaxRelateObjectInfoTag extends RelatedObjectInfoTag {

  private Log log = LogFactory.getLog(this.getClass());
  AjaxWriter out = null;
  
  /**
   * befor use this method ,please set the Parameters.see the super class RelatedObjectInfoTag
   * @return
   * @throws Exception
   */
  public String getAjaxContent() throws ApplicationException{
    try{
      out = (AjaxWriter)pageContext.getOut();
      out.clear();
      this.doStartTag();
      this.doEndTag();
      return out.getContent().toString();
    }catch(IOException ex){
      log.error(ex.getMessage(), ex);
      throw new ApplicationException(ex);
    }catch(JspException ex){
      log.error(ex.getMessage(), ex);
      throw new ApplicationException(ex);
    }
    //return content;
  }

  public PageContext getPageContext() {
    return pageContext;
  }

  public void setPageContext(PageContext pageContext) {
    this.pageContext = pageContext;
  }
}
